package adapter;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;

import data.SiloAdress;

public class ConfigFileAdapter {

	public ArrayList<SiloAdress> readConfigFile(File file) throws Exception {
		ArrayList<SiloAdress> result = new ArrayList<SiloAdress>();
		Document doc = new SAXBuilder().build(file);
		Element test = doc.getRootElement();
		List<Element> children = test.getChildren();
		for (Element element : children) {
			result.add(new SiloAdress(element.getChild("IPAdresse").getValue(),
					element.getChild("Port").getValue()));
		}

		return result;
	}
}
